
package com.xx.entity;

import java.io.Serializable;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * 
 * @TableName cqcet.datasource
 * @description 数据源 
 */
@Data
@TableName("cqcet.datasource")
@ApiModel
public class Datasource implements Serializable {
    
	/**
	 * ID
	 */
	@TableId(type = IdType.ASSIGN_ID)
	@ApiModelProperty("ID")
	@JsonSerialize(using = ToStringSerializer.class)
	private Long id;
			
    /**
     * 名称
	 * 
     */
    @ApiModelProperty("名称")
    private String name;
				
    /**
     * 所属模块
	 * 
     */
    @ApiModelProperty("所属模块")
    private String pjectId;
				
    /**
     * IP
	 * 
     */
    @ApiModelProperty("IP")
    private String host;
				
    /**
     * 端口
	 * 
     */
    @ApiModelProperty("端口")
    private Integer port;
				
    /**
     * 库名
	 * 
     */
    @ApiModelProperty("库名")
    private String dbn;
				
    /**
     * 用户名
	 * 
     */
    @ApiModelProperty("用户名")
    private String user;
				
    /**
     * 密码
	 * 
     */
    @ApiModelProperty("密码")
    private String password;
				
	/**
	 * 创建时间
	 */
	@TableField(fill = FieldFill.INSERT)
	@ApiModelProperty("创建时间")
	@JsonSerialize(using = ToStringSerializer.class)
	private Long createTime;
				  
	/**
	 * 创建时间
	 */
	@TableField(fill = FieldFill.INSERT)
	@ApiModelProperty("创建时间")
	private String createTimeString;
					
	/**
	 * 更新时间
	 */
	@TableField(fill = FieldFill.UPDATE)
	@ApiModelProperty("更新时间")
	@JsonSerialize(using = ToStringSerializer.class)
	private Long updateTime;
					
	/**
	 * 更新时间
	 */
	@TableField(fill = FieldFill.UPDATE)
	@ApiModelProperty("更新时间")
	private String updateTimeString;
					
	/**
	 * 逻辑删除控制
	 */
	@ApiModelProperty("逻辑删除控制")
	@TableLogic
	private Integer state;
			  
	/**
	 * 单位
	 */
	@TableField(fill = FieldFill.INSERT)
	@ApiModelProperty("单位")
	private String unitId;
					
	
	/**
	 * 设置ID
	 */
	public void setId(Long id){
		this.id = id;
	}

	/**
	 * 获取ID
	 */
	public Long getId(){
		return this.id;
	}
		
	/**
	 * 设置名称
	 */
	public void setName(String name){
		this.name = name;
	}

	/**
	 * 获取名称
	 */
	public String getName(){
		return this.name;
	}
		
	/**
	 * 设置所属模块
	 */
	public void setPjectId(String pjectId){
		this.pjectId = pjectId;
	}

	/**
	 * 获取所属模块
	 */
	public String getPjectId(){
		return this.pjectId;
	}
		
	/**
	 * 设置IP
	 */
	public void setHost(String host){
		this.host = host;
	}

	/**
	 * 获取IP
	 */
	public String getHost(){
		return this.host;
	}
		
	/**
	 * 设置端口
	 */
	public void setPort(Integer port){
		this.port = port;
	}

	/**
	 * 获取端口
	 */
	public Integer getPort(){
		return this.port;
	}
		
	/**
	 * 设置库名
	 */
	public void setDbn(String dbn){
		this.dbn = dbn;
	}

	/**
	 * 获取库名
	 */
	public String getDbn(){
		return this.dbn;
	}
		
	/**
	 * 设置用户名
	 */
	public void setUser(String user){
		this.user = user;
	}

	/**
	 * 获取用户名
	 */
	public String getUser(){
		return this.user;
	}
		
	/**
	 * 设置密码
	 */
	public void setPassword(String password){
		this.password = password;
	}

	/**
	 * 获取密码
	 */
	public String getPassword(){
		return this.password;
	}
		
	/**
	 * 设置创建时间
	 */
	public void setCreateTime(Long createTime){
		this.createTime = createTime;
	}

	/**
	 * 获取创建时间
	 */
	public Long getCreateTime(){
		return this.createTime;
	}
		
	/**
	 * 设置创建时间
	 */
	public void setCreateTimeString(String createTimeString){
		this.createTimeString = createTimeString;
	}

	/**
	 * 获取创建时间
	 */
	public String getCreateTimeString(){
		return this.createTimeString;
	}
		
	/**
	 * 设置更新时间
	 */
	public void setUpdateTime(Long updateTime){
		this.updateTime = updateTime;
	}

	/**
	 * 获取更新时间
	 */
	public Long getUpdateTime(){
		return this.updateTime;
	}
		
	/**
	 * 设置更新时间
	 */
	public void setUpdateTimeString(String updateTimeString){
		this.updateTimeString = updateTimeString;
	}

	/**
	 * 获取更新时间
	 */
	public String getUpdateTimeString(){
		return this.updateTimeString;
	}
		
	/**
	 * 设置逻辑删除控制
	 */
	public void setState(Integer state){
		this.state = state;
	}

	/**
	 * 获取逻辑删除控制
	 */
	public Integer getState(){
		return this.state;
	}
		
	/**
	 * 设置单位
	 */
	public void setUnitId(String unitId){
		this.unitId = unitId;
	}

	/**
	 * 获取单位
	 */
	public String getUnitId(){
		return this.unitId;
	}
		
	public String stringify(){
		String rc = "{\"id\":\"" + this.getId() + "\",\"name\":\"" + this.getName() + "\",\"pjectId\":\"" + this.getPjectId() + "\",\"host\":\"" + this.getHost() + "\",\"port\":\"" + this.getPort() + "\",\"dbn\":\"" + this.getDbn() + "\",\"user\":\"" + this.getUser() + "\",\"password\":\"" + this.getPassword() + "\",\"createTime\":\"" + this.getCreateTime() + "\",\"createTimeString\":\"" + this.getCreateTimeString() + "\",\"updateTime\":\"" + this.getUpdateTime() + "\",\"updateTimeString\":\"" + this.getUpdateTimeString() + "\",\"state\":\"" + this.getState() + "\",\"unitId\":\"" + this.getUnitId() + "\"}";
		rc = rc.replaceAll("\"null\"","null").replaceAll("\"([0-9]+)\"","$1");
        return rc;
	}

	public static Datasource JSONparse(String jsonString) throws JsonProcessingException {
        if(jsonString == null) return null;
		try {
            ObjectMapper objectMapper = new ObjectMapper();
            return objectMapper.readValue(jsonString,Datasource.class);
        }catch (JsonProcessingException e){
            return null;
        }
    }
}
    